package com.shujia.day14;

import java.util.HashSet;

public class HashSetDemo2 {
    public static void main(String[] args) {
        //使用HashSet存储学生对象元素，当学生的姓名和年龄一样的时候，认为重复了
        HashSet<Student> set1 = new HashSet<>();

        Student s1 = new Student("李刚", 18);
        Student s2 = new Student("钱志强", 16);
        Student s3 = new Student("刘亦菲", 18);
        Student s4 = new Student("李刚", 18);
        Student s5 = new Student("吴问强", 19);

        set1.add(s1);
        set1.add(s2);
        set1.add(s3);
        set1.add(s4);
        set1.add(s5);

        for (Student student : set1) {
            System.out.println(student);
        }
    }
}
